<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">   
<script src="js/jquery-1.9.1.js"></script>

	<title>手写签名</title>
</head>

<body>

<div class="js-signature"  data-height="200" data-width="600" data-border="2px solid black" data-line-color="#330000" >
</div>
<p><button id="clearBtn" class="btn btn-default" onclick="clearCanvas();">清除</button>&nbsp;&nbsp;&nbsp;
<button id="saveBtn" class="btn btn-default" onclick="saveSignature('tool');" disabled="disabled">保存</button>&nbsp;&nbsp;&nbsp;
<button id="list" class="btn btn-default" onclick="list();" >返回列表</button></p>
<p >反馈消息：</p><p class="result"></p>
<script src="index_data/jquery.js" type="text/javascript"></script>
<script>window.jQuery || document.write('<script src="js/jquery-1.11.0.min.js"><\/script>')</script>
<script src="index_data/jq-signature.js"></script>
<script type="text/javascript">
	$(document).on('ready', function() {
		if ($('.js-signature').length) {
			$('.js-signature').jqSignature();
		}
	});

	function clearCanvas() {
		
		$('.js-signature').eq(0).jqSignature('clearCanvas');
		$('#saveBtn').attr('disabled', true);
	}

	function list() {
		
		 var url ="../index.php"; 
			window.location.href=url;
	}

	function saveSignature(class1) {
		var dataUrl = $('.js-signature').eq(0).jqSignature('getDataURL');
		var img = $('<img>').attr('src', dataUrl);
		$.post('save.php',{data:dataUrl,class1:class1,ID:$_GET['ID'] ,person:$_GET['person'] },function(data) {
		//保存按钮显示
				$('#saveBtn').attr('disabled', true);
		  //现实签名结果
		$(".result").text("图像"+data);
	//	alert("图像"+data)
	   //返回上一页
		//history.go(-1);  
		if($_GET['ctr']=='index'){ 
			var url ="../"+$_GET['ctr']+".php?&ID=" + $_GET['ID']; 
		}else{
			var url="../index.php";
		}
	
	window.location.href=url;


   })	
		}
	//返回 $_GET 对象, 仿PHP模式
	var $_GET = (function(){
		var url = window.document.location.href.toString();
		var u = url.split("?");
		if(typeof(u[1]) == "string"){
			u = u[1].split("&");
			var get = {};
			for(var i in u){
				var j = u[i].split("=");
				get[j[0]] = j[1];
			}
			return get;
		} else {
			return {};
		}
	})();
//
$('.js-signature').eq(0).on('jq.signature.changed', function() {
			$('#saveBtn').attr('disabled', false);
		});
	</script>
</body></html>